package com.aiyige.model.sns;

import android.text.TextUtils;

import com.aiyige.model.sns.backup.SnsMineBackup;
import com.aiyige.model.sns.backup.SnsUserBackup;

/**
 * Created by zhuyakun on 2018/1/31.
 */

public class Follow {
    String id;
    String followerId;
    String beFollowedId;
    Long createTime;
    SnsUserBackup followUserBackup;
    SnsMineBackup mineBackup;
    Boolean mutualFollower;

    public Follow() {
    }

    public Follow(Follow other) {
        id = TextUtils.isEmpty(other.getId()) ? "" : other.getId();
        followerId = TextUtils.isEmpty(other.getFollowerId()) ? "" : other.getFollowerId();
        beFollowedId = TextUtils.isEmpty(other.getBeFollowedId()) ? "" : other.getBeFollowedId();
        createTime = other.getCreateTime() == null ? 0l : other.getCreateTime();
        mutualFollower = other.getMutualFollower() == null ? false : other.getMutualFollower();
        if (other.getFollowUserBackup() == null) {
            followUserBackup = new SnsUserBackup();
            followUserBackup.setAvatar("");
            followUserBackup.setId("");
            followUserBackup.setName("");
            followUserBackup.setSex("");
            followUserBackup.setLevel("");
        } else {
            followUserBackup = new SnsUserBackup(other.getFollowUserBackup());
        }

        if (other.getMineBackup() == null) {
            mineBackup = new SnsMineBackup();
            mineBackup.setMyFollowId("");
            mineBackup.setIsMe(SnsMineBackup.IS_ME_NO);
        } else {
            mineBackup = new SnsMineBackup(other.getMineBackup());
        }
    }

    private Follow(Builder builder) {
        setId(builder.id);
        setFollowerId(builder.followerId);
        setBeFollowedId(builder.beFollowedId);
        setCreateTime(builder.createTime);
        setFollowUserBackup(builder.followUserBackup);
        setMineBackup(builder.mineBackup);
        setMutualFollower(builder.mutualFollower);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getFollowerId() {
        return followerId;
    }

    public void setFollowerId(String followerId) {
        this.followerId = followerId;
    }

    public String getBeFollowedId() {
        return beFollowedId;
    }

    public void setBeFollowedId(String beFollowedId) {
        this.beFollowedId = beFollowedId;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public SnsUserBackup getFollowUserBackup() {
        return followUserBackup;
    }

    public void setFollowUserBackup(SnsUserBackup followUserBackup) {
        this.followUserBackup = followUserBackup;
    }

    public SnsMineBackup getMineBackup() {
        return mineBackup;
    }

    public void setMineBackup(SnsMineBackup mineBackup) {
        this.mineBackup = mineBackup;
    }

    public Boolean getMutualFollower() {
        return mutualFollower;
    }

    public void setMutualFollower(Boolean mutualFollower) {
        this.mutualFollower = mutualFollower;
    }


    public static final class Builder {
        private String id;
        private String followerId;
        private String beFollowedId;
        private Long createTime;
        private SnsUserBackup followUserBackup;
        private SnsMineBackup mineBackup;
        private Boolean mutualFollower;

        private Builder() {
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder followerId(String val) {
            followerId = val;
            return this;
        }

        public Builder beFollowedId(String val) {
            beFollowedId = val;
            return this;
        }

        public Builder createTime(Long val) {
            createTime = val;
            return this;
        }

        public Builder followUserBackup(SnsUserBackup val) {
            followUserBackup = val;
            return this;
        }

        public Builder mineBackup(SnsMineBackup val) {
            mineBackup = val;
            return this;
        }

        public Builder mutualFollower(Boolean val) {
            mutualFollower = val;
            return this;
        }

        public Follow build() {
            return new Follow(this);
        }
    }
}
